package cn.lingyangwl.agile.common.feign.content;

import com.alibaba.ttl.TransmittableThreadLocal;

import java.util.Objects;

/**
 *
 * @author shenguangyang
 */
public class FeignRequestContentHolder {
    private static final TransmittableThreadLocal<FeignRequestContent> THREAD_LOCAL = new TransmittableThreadLocal<>();

    public static void set(FeignRequestContent content) {
        THREAD_LOCAL.set(content);
    }

    public static FeignRequestContent get() {
        FeignRequestContent feignRequestContent = THREAD_LOCAL.get();
        if (Objects.isNull(feignRequestContent)) {
            feignRequestContent = new FeignRequestContent();
            THREAD_LOCAL.set(feignRequestContent);
        }
        return feignRequestContent;
    }

    public static void remove() {
        THREAD_LOCAL.remove();
    }
}